﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Windows.Forms;

namespace Class_and_instance
{
    internal class Program
    {
        static void Main(string[] args)
        {
            new Form();     //创建后会被自动销毁

            //(new Form()).Text = "My Form" //改窗口名
            //(new Form()).ShowDialog();    //实际上是又创建了一个实例并显示

            Form MyForm1;    //创建引用变量
            Form MyForm2;

            MyForm1 = new Form();    //链接引用变量到新建的Form实例

            MyForm2 = MyForm1;  

            MyForm2.Text = "My Form";    //2 间接操作Form实例

            MyForm1.ShowDialog();        //1 显示 
        }
    }
}
